package com.design.create.singleton;

/**
 * volatile和synchronized实现双重校验锁的懒汉式单例
 */
public class DoubleSyncLazySingleton {

    private DoubleSyncLazySingleton() {}

    private static volatile DoubleSyncLazySingleton doubleSyncLazySingleton = null;

    public static DoubleSyncLazySingleton getInstance() {
        if (doubleSyncLazySingleton == null) {
            synchronized (DoubleSyncLazySingleton.class) {
                if (doubleSyncLazySingleton == null) {
                    doubleSyncLazySingleton = new DoubleSyncLazySingleton();
                }
            }
        }
        return doubleSyncLazySingleton;
    }
}
